interface GoodsTypeValidPeriod {
    verify_start_day: string
    verify_end_day: string
    valid_period: string | number
}

// 闪购/拼团 商品
export const getGoodsValidPeriodDetail = (row: GoodsTypeValidPeriod, text = '购买') => {
    if (row.verify_start_day) {
        return `${row.verify_start_day.slice(0, 16)}至${row.verify_end_day.slice(0, 16)}`;
    } else if (row.valid_period || row.valid_period === 0) {
        if (+row.valid_period > 0) {
            return `${text}后${row.valid_period}天内有效`;
        } else {
            return `${text}后当天内有效`;
        }
    }
}

export interface CouponTypeValidPeriod {
    period_type: number
    start_at: string
    end_at: string
    valid_period: string | number
}

// 优惠券
export const getCouponValidPeriodDetail = (row: CouponTypeValidPeriod, text: string = '领取优惠券') => {
    return getValidPeriodDetail(row, text);
}
// 有价券
export const getValuableValidPeriodDetail = (row: CouponTypeValidPeriod, text: string = '购买') => {
    return getValidPeriodDetail(row, text);
}
// 获取有效期 详情信息
export const getValidPeriodDetail = (row: CouponTypeValidPeriod, text: string = '') => {
    if (row.start_at) {
        return `${row.start_at.slice(0, 16)}至${row.end_at.slice(0, 16)}`;
    } else if (row.valid_period || row.valid_period === 0) {
        if (+row.valid_period > 0) {
            return `${text}后${row.valid_period}天有效`;
        } else {
            return `${text}后当天有效`;
        }
    }
    // if (row.period_type === 1) {
    //     return row.start_at && row.end_at ? `${row.start_at.slice(0, 16)}至${row.end_at.slice(0, 16)}` : '';
    // }
    // if (row.period_type === 2) {
    //     if (row.valid_period || row.valid_period === 0) {
    //         if (+row.valid_period > 0) {
    //             return `${text}后${row.valid_period}天有效`;
    //         } else {
    //             return `${text}后当天有效`;
    //         }
    //     }
    // }
    // if (row.period_type === 3) {
    //     return `${text}后当月有效`;
    // }
    // return '';
}